import request from '@/utils/request'
import {
  encrypt
} from '@/utils/rsaEncrypt'

export function pageList(data) {
  return request({
    url: 'api/sysUser/pagelist',
    method: 'post',
    data
  })
}

export function modify(data) {
  return request({
    url: 'api/sysUser/modifySysUser',
    method: 'post',
    data
  })
}

export function updateUserEnabled(id) {
  return request({
    url: 'api/sysUser/updateUserEnabled?id='+id,
    method: 'get'
  })
}

export function del(id) {
  return request({
    url: 'api/sysUser/'+id,
    method: 'delete'
  })
}

export function get(id) {
  return request({
    url: 'api/sysUser/'+id,
    method: 'get'
  })
}

export function updatePass(user) {
  const data = {
    oldPass: encrypt(user.oldPass),
    newPass: encrypt(user.newPass)
  }
  return request({
    url: 'api/sysUser/updatePass/',
    method: 'post',
    data
  })
}

export default {
  modify,del,get,updateUserEnabled,pageList
}
